package com.xqt.dao.dict;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.xqt.base.dao.BaseDao;
import com.xqt.base.entity.BaseEntity;
import com.xqt.entity.dict.DictBase;

/**
 * Desc:
 * Author:liubo
 * Date: 2017-03-21 15:51
 **/
@Repository
public class DictDao extends BaseDao<DictBase> {
    @Override
    public String getReadSql() {
        return "read.dict.";
    }

    @Override
    public String getWriteSql() {
        return "write.dict.";
    }


    /**
     * 获取唯一的字典值
     */
    public DictBase getDictLabel(DictBase dictBase){
        return readSqlSession.selectOne(getReadSql()+"getDictLabel",dictBase);
    };
    /**
     * 获取唯一的字典value
     * @param dictBase
     * @return
     */
    public DictBase getDictName(DictBase dictBase){
        return readSqlSession.selectOne(getReadSql()+"getDictName",dictBase);
    }
    /**
     * 获取多个字典值
     * @param dictBase
     * @return
     */
    public List<DictBase> getDictLabels(DictBase dictBase){
        return readSqlSession.selectList(getReadSql()+"getDictLabels",dictBase);
    }

    /**
     * 根绝dictType获取字典列表
     * @param dictType
     * @return
     */
    public List<DictBase> getDictList(Object dictType){
        return readSqlSession.selectList(getReadSql()+"getDictList",dictType);
    }

    /**
     * 根据Type获取到字典类型
     */
    public DictBase queryByType(DictBase dictBase){
        return readSqlSession.selectOne(getReadSql()+"queryByType",dictBase);
    }

    /**
     * 获取字典类型列表的数量
     * @param page
     * @return
     */
    public int queryTypeByCount(BaseEntity page){
        return readSqlSession.selectOne(getReadSql()+"queryTypeByCount",page);
    }

    /**
     * 获取字典类型列表
     * @param page
     * @return
     */
    public List<DictBase> queryTypeByList(BaseEntity page){
        return readSqlSession.selectList(getReadSql()+"queryTypeByList",page);
    }

    /**
     * 验证字典是否存在
     * @param dictBase
     * @return
     */
    public List<DictBase> checkDictExist(DictBase dictBase){
        return readSqlSession.selectList(getReadSql()+"checkDictExist",dictBase);
    }



}
